package com.cgt.day6;

import org.junit.Test;

public class PackageDemo {
    @Test
    public void test1(){
        //老方法,从java9被废除
        Integer integer1 = new Integer(3);
        System.out.println(integer1);
        //3

        //新方法，int向integer转化
        Integer integer2 = Integer.valueOf(4);
        System.out.println(integer2);
        //4

        //integer最大为2^31-1
        System.out.println(Integer.MAX_VALUE);
        //2147483647
        //A constant holding the maximum value an int can have, 2^31-1
    }

    @Test
    public void test2(){
        Integer integer1 = Integer.valueOf(3);
        System.out.println(integer1);//3

//        Integer integer2 = Integer.valueOf(3);
        Integer integer2 = 4;//自动装箱
        System.out.println(integer2);

//        int i =integer2.intValue();
        int num1 = integer2;//自动拆箱
        System.out.println(num1);

        Integer integer3 = 5;
        int num2 = integer3 + 6;//拆箱使用 5 + 6 = 11
        System.out.println(num2);
        integer3 = integer3 + 5;//先拆后装 5 + 5 =10
        System.out.println(integer3);
    }

    @Test
    public void test3(){
        String str1 = 123 + "";
        String str2 = 3.12 + "";
        String str3 = Double.toString(3.12);

        int i = Integer.parseInt("23");
        double d = Double.parseDouble("3.14");
        float f = Float.parseFloat("123");
//        System.out.println(f);
//        Integer integer =  new Integer("4");
        Integer integer = Integer.valueOf("4");
        System.out.println(integer.intValue());
    }
}
